﻿using SelfMadeMillionaire.Core.Entities;
using SelfMadeMillionaire.Core.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SelfMadeMillionaire.DAL.Repositories
{
	public class NewsletterRepository : Repository<Newsletter>, INewsletterRepository
	{
		public NewsletterRepository(IUnitOfWork uow)
			: base(uow)
		{
		}

		public override Newsletter Update(Newsletter entity)
		{
			var dbEntity = Get(entity.ID);

			dbEntity.Title = entity.Title;
			dbEntity.PdfFileName = entity.PdfFileName;
			dbEntity.IssueType = entity.IssueType;
			dbEntity.Letter = entity.Letter;
			dbEntity.Symbols = entity.Symbols;
			dbEntity.Date = entity.Date;
			dbEntity.MinAccessLevel = entity.MinAccessLevel;
            dbEntity.MinAccessLevelOriginal = entity.MinAccessLevelOriginal;

			Commit();

			return dbEntity;
		}

		public IEnumerable<IssueType> GetIssueTypes()
		{
			return _uow.GetDbSet<IssueType>();
		}
	}
}
